package com.young.fragments.demo.lazy_show_demo.fms

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.young.fragments.databinding.FmLazyShow1Binding
import com.young.fragments.demo.lazy_show_demo.LazyShowActivity1
import com.young.lib_fragments.fms.BaseLazyFragment

/**
 * @author huangzehui
 * @date 2025/1/24 13:00 周五
 * @description 懒加载 Fragment 3
 */
class LazyShowFragment3 : BaseLazyFragment() {


    private lateinit var mBinding: FmLazyShow1Binding

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        Log.e("young_test909090909", "onViewCreated = ${this}")
    }

    override fun onResume() {
        super.onResume()
        Log.e("young_test909090909", "onResume = ${this}")
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        Log.e("young_test909090909", "onCreateView = ${this}")
        mBinding = FmLazyShow1Binding.inflate(inflater, container, false)
        return mBinding.root
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.e("young_test909090909", "onCreate = ${this}")
    }

    override fun onFirstSupportVisible() {
        super.onFirstSupportVisible()
        mBinding.llLoading.visibility = View.GONE
        mBinding.tvContent.text = "页面3"

        if (requireActivity() is LazyShowActivity1){
            mBinding.tvContent.text = "点我，进入下一页"
            mBinding.tvContent.setOnClickListener {
//                (requireActivity() as LazyShowActivity1). start(LazyShowFragment4(), isToBackStack = true)
                start(LazyShowFragment4(), isToBackStack = true)
            }
        }
    }

}